﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Threading;

namespace _17_WindowsService
{
    public partial class MyService : ServiceBase
    {
        protected bool bWork;

        public MyService()
        {
            InitializeComponent();
            bWork = true;
        }

        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.
            new Thread(new ThreadStart(this.doMyFunction)).Start();
        }

        protected void doMyFunction()
        {
            while (bWork)
            {
                Thread.Sleep(100);
            }
        }

        protected override void OnStop()
        {
            // TODO: Add code here to perform any tear-down necessary to stop your service.
            bWork = false;
        }
    }
}
